package com.qf.controller;

import com.qf.pojo.Order;
import com.qf.pojo.UserInfo;
import com.qf.pojo.resp.BaseResult;
import com.qf.service.FeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/fee")
@CrossOrigin
public class FeeController {
    @Autowired
    FeeService feeService;
    @RequestMapping("/findById")
    public BaseResult findByUid(HttpSession session){
        session.setAttribute("user",new UserInfo(1,"zhangsan"));
        UserInfo user = (UserInfo) session.getAttribute("user");
        Integer uid = user.getId();
        System.out.println(uid+"============");
        BaseResult all = feeService.findByUid(uid);
        return all;
    }

    /**
     * 修改费用updateDianMoney
     * @param order
     * @return
     */
    @RequestMapping("/updateWaterMoney")
    public BaseResult updateWaterMoney(@RequestBody Order order){
        return feeService.updateWaterMoney(order);
    }

    @RequestMapping("/updateDianMoney")
    public BaseResult updateDianMoney(@RequestBody Order order){
        return feeService.updateDianMoney(order);
    }
}
